package com.example.chesswithnet.Controller;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.stage.Stage;

import java.io.IOException;

public class BaseController {

    public void newStage(String fxml,BaseController controller,String title) throws IOException {
        Stage stage = new Stage();
        stage.setX(800);
        stage.setY(300);
//        Parent root = FXMLLoader.load(getClass().getResource(fxml));
        FXMLLoader loader = new FXMLLoader(getClass().getResource(fxml));
        if(controller != null)
            loader.setController(controller);
//        stage.show();
        Parent root = loader.load();
        stage.setTitle(title);
        stage.setScene(new Scene(root));
//        stage.initModality(APPLICATION_MODAL);
        stage.show();

    }

    public void alert(Alert.AlertType alertType, String message){
        Alert alert = new Alert(alertType);
        alert.setContentText(message);
        alert.showAndWait();
    }

}
